﻿$(document).ready(function() 
{
//    var data = [{colunm1:"1",colunm2:"欄位",colunm3:"名稱",colunm4:"資料",colunm5:"測試",colunm6:"20130426"},
//                {colunm1:"2",colunm2:"欄位",colunm3:"名稱",colunm4:"資料",colunm5:"測試",colunm6:"20130426"},
//                {colunm1:"3",colunm2:"欄位",colunm3:"名稱",colunm4:"資料",colunm5:"測試",colunm6:"20130426"},
//                {colunm1:"4",colunm2:"欄位",colunm3:"名稱",colunm4:"資料",colunm5:"測試",colunm6:"20130426"},
//                {colunm1:"5",colunm2:"欄位",colunm3:"名稱",colunm4:"資料",colunm5:"測試",colunm6:"20130426"},
//                {colunm1:"6",colunm2:"欄位",colunm3:"名稱",colunm4:"資料",colunm5:"測試",colunm6:"20130426"},
//                {colunm1:"7",colunm2:"欄位",colunm3:"名稱",colunm4:"資料",colunm5:"測試",colunm6:"20130426"},
//                {colunm1:"8",colunm2:"欄位",colunm3:"名稱",colunm4:"資料",colunm5:"測試",colunm6:"20130426"},
//                {colunm1:"9",colunm2:"欄位",colunm3:"名稱",colunm4:"資料",colunm5:"測試",colunm6:"20130426"}];
   $("#master").grid({height:540,
                      autowidth:true,
                      multiselect: false,
                      rowNum:10,
                      colModel:[
                    //{ label: "用户ID", name: "USER_ID", hidden:"true",key:"true", align: "center"},
                    { label: "用户名称", name: "USER_NAME", index: "USER_NAME", width: 60, align: "center" },
                    { label: "登陆帐号", name: "LOGIN_NAME", index: "LOGIN_NAME", width: 60, align: "left" } ,
                    { label: "厂别代号", name: "FACT_NO", index: "FACT_NO", width: 40, align: "center" },
                    { label: "厂别", name: "FACT_NM", index: "FACT_NM",  align: "center" },
                    { label: "部门", name: "DEPT_NM", index: "DEPT_NM", width: 80, align: "center" },
                    { label: "状态", name: "STOP_MK", index: "STOP_MK", width: 40, align: "center", formatter: function(cellValue, options, row) { return cellValue == "Y" ? "已停用" : "已启用"; } },
                    //{ label: "权限群组", width: 60, align: "center", sortable: false, formatter: function(cellValue, options, row) { return "<a href='#' onclick='OpenUploadPage(" + row.USER_ID + ",2);'><font color=blue>设定</font></a>"; } },
                    { label: "重置密码", width: 60, align: "center", sortable: false, formatter: function(cellValue, options, row) { return "<a href='#' onclick='ResetPWD(" + row.USER_ID + ");'><font color=blue>重置密码</font></a>"; } },
                    { label: "修改", id: "modi", width: 40, align: "center", sortable: false, formatter: function(cellValue, options, row) { return "<a href='#' onclick='modiDetail(" + row.USER_ID + ",3);'><font color=blue>修改</font></a>"; } },
                    { label: "停/启用", id: "active",width:40, align: "center", sortable: false, formatter: function(cellValue, options, row) { return "<a href='#' onclick='ActiveStopUser(\"" + row.USER_ID + "\",\""+ row.STOP_MK +"\");'>"+(row.STOP_MK=="Y"?"<font color=blue>启用":"<font color=gray>停用")+"</font></a>"; } }
                                //{label: "欄位五", name: "colunm6", align: "left"}]
                        ]});
      searchData();
});

function openDialog()
{
    top.$.pdialog.open({url:"pages/dataform/UserAdd.aspx",id:"useradd",title:"用戶管理",min:false,mask:true});
} 

function searchData()
{
    top.Core.AJAX.Post({dataType:"json",
    data:{MothodName: "BusWEB.WFInterface.Users.GetUsers",factNo:$("#factno").val(),deptNo:"",userName:$("#username").val(),loginName:$("#loginname").val()},
    fn:function(data)
    { 
       $("#master").gridBind(data.rows);
    }});

}